//
// Created by root on 10/28/17.
//

#include "constants.h"
#include "clog.h"
#include "../support/log/zlog.h"

int log_init(char *logConfigFilePath) {
    int rc = zlog_init(logConfigFilePath);
    if (rc) {
        printf("init failed\n");
        return FALSE;
    }
    return TRUE;
}

void log_finish() {
    zlog_fini();
}

void log_fatal(char *category, char *message) {
    zlog_category_t *c = zlog_get_category(category);
    if (!c) {
        printf("get cat fail\n");
        zlog_fini();
    }
    zlog_fatal(c, message);
}

void log_error(char *category, char *message) {
    zlog_category_t *c = zlog_get_category(category);
    if (!c) {
        printf("get cat fail\n");
        zlog_fini();
    }
    zlog_error(c, message);
}

void log_warn(char *category, char *message) {
    zlog_category_t *c = zlog_get_category(category);
    if (!c) {
        printf("get cat fail\n");
        zlog_fini();
    }
    zlog_warn(c, message);
}

void log_info(char *category, char *message) {
    zlog_category_t *c = zlog_get_category(category);
    if (!c) {
        printf("get cat fail\n");
        zlog_fini();
    }
    zlog_info(c, message);
}

void log_debug(char *category, char *message) {
    zlog_category_t *c = zlog_get_category(category);
    if (!c) {
        printf("get cat fail\n");
        zlog_fini();
    }
    zlog_debug(c, message);
}

